package views
{
	import events.ListViewEvent;
	
	import flash.display.MovieClip;
	import flash.text.TextField;
	import flash.text.TextFieldAutoSize;
	
	import models.ListViewModel;

	public class ViewData extends MovieClip
	{
		private var listModel:ListViewModel;
		private var clip:MovieClip;
		public function ViewData($clip:MovieClip)
		{
			super();
			init($clip);
		}
		private function init($clip:MovieClip):void
		{
			clip=$clip;
			listModel=new ListViewModel();
			listModel.addEventListener(ListViewEvent.LIST_LOADED,getData);
		}
		private function getData(evt:ListViewEvent):void
		{
			var xml:XMLList=evt.target.data;
			for(var i:int=0;i<xml.length();i++){
				var txt:TextField=new TextField();
				txt.wordWrap=true;	
				txt.autoSize=TextFieldAutoSize.LEFT;
				txt.name="txt_"+i;
				txt.text=xml[i].@url;
				txt.width=txt.textWidth+30;
				txt.y=i*20;				
				clip.addChild(txt);
			}
			//trace(xml.length()+"\t"+clip);
		}
	}
}